package anji.plus.system.mark.base;

import anji.plus.system.mark.exception.BusinessException;
import anji.plus.system.mark.response.ResponseCode;
import cn.hutool.core.util.StrUtil;

/**
 * <p>
 *
 * </p>
 *
 * @author zag
 * @since 2023/7/17
 */
public class Header {

    private static final  String AUTHORIZATION_BEARER_TOKEN = "Basic ";


    public static String getAuthorization(String header){
        if (StrUtil.isBlank(header)||header.startsWith(AUTHORIZATION_BEARER_TOKEN)){
            throw new BusinessException(ResponseCode.USER_NOT_LOGGED_IN);
        }
        return header.substring(AUTHORIZATION_BEARER_TOKEN.length()+1);
    }
}
